﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Guoc.DAL.Common;
using Guoc.DAL.Domain;
using Guoc.DAL.Interface;
using NHibernate.Linq;
using NHibernate;
using NHibernate.Criterion;
namespace Guoc.DAL.Service
{
   public class RoleService:BaseService<Role>,IRole
    {


        public List<Role> QueryRoleList(string roleName, int page, int rows, out int count)
        {
            List<Role> list = new List<Role>();
            if (string.IsNullOrEmpty(roleName))
            {
                //如果为null 查询所有
                list = GetList(page, rows,out count);
            }
            else
            {
                list = base.LinqQuery.Where(r => r.RoleName.Contains(roleName)).Skip((page - 1) * rows).Take(rows).ToList();

                count = base.LinqQuery.Where(r => r.RoleName.Contains(roleName)).Count();
            }          
             
            return list;
        }


        public bool Delete(string ids)
        {
            return base.ExecuteHql("Delete from Role r where r.RoleID in (" + ids + ")");
        }
    }
}
